package sean.org;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;

@Configuration
@ComponentScan("sean.org")
@PropertySource("classpath:sean/org/test.properties")
public class ElConfig {

	@Value("I love you")
	private String normal;
	
	@Value("#{systemProperties['os.name']}")
	private String osName;
	
	@Value("#{demoService.author}")
	private String fromAuthor;
	
	@Value("${book.author}")
	private String author1;
	
	//注意添加这个bean不然@Value获取不到配置文件中的值
	@Bean
	public static PropertySourcesPlaceholderConfigurer propertyConfigure(){
		return new PropertySourcesPlaceholderConfigurer();
	}
	
	public void output(){
		System.out.println(normal);
		System.out.println(osName);
		System.out.println(fromAuthor);
		System.out.println(author1);
	}
	
	
}
